<?php

/**
 * 73YC 标签云
 * ============================================================================
 * * 版权所有 20013-* 梅州络客网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.alork.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: index.php 17217 2013-10-19 06:29:08Z liubo $
*/

define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
assign_template();
if(!empty($_REQUEST['act']) && $_REQUEST['act'] == 'join'){
    $smarty->assign('act', $_REQUEST['act']);
    $smarty->display('alone.html', $cache_id);
}
/*注册验证*/
elseif(!empty($_REQUEST['act']) && $_REQUEST['act'] == 'send_sms'){
    require(ROOT_PATH . 'includes/cls_json.php');
    $json   = new JSON;
        require(ROOT_PATH . '/plugins/sms2.php'); //引入接口文件
        $code = rand('100000','999999');
        $mobile = intval($_POST['mobile']);
        $sql = "SELECT user_id FROM " . $ecs->table('users') . " WHERE mobile_phone = '$mobile' OR user_name = '$mobile' OR email = '$mobile'";
        $user_id = $db->getOne($sql);
        if(!$user_id){
            $text = "【鸡蛋美术】您的验证码是:" . $code."该验证码用于用户注册";//短信内容
            $data = send_sms($text, $mobile);
            $data = get_object_vars(json_decode($data));
            if($data['msg'] == 'OK'){
                /*注册验证码*/
                $_SESSION['registerCaptcha'] = $code;
                $_SESSION['mobile'] = $mobile;
            }
        }else{
            $data['msg'] = 'NO';
            $data['message'] = '手机号已经被使用！';
            $data['error'] = 503;
        }
        echo $json->encode($data);
        exit;
}
else{
    header('location:index.php');
}
?>